#pragma once

#ifndef PARTICLE_H
#define PARTICLE_H

#include "Entity.h"
#include "Animation.h"

class Particle
{
public:
	D3DXVECTOR3 position;
    D3DXVECTOR3 velocity;
	D3DXVECTOR3 acceleration;
	float mass;
	float inverseMass;
	float damping;
	D3DXVECTOR3 force;
	Particle(D3DXVECTOR3 position, D3DXVECTOR3 velocity, float mass)
	{
        this->position = position;
        this->velocity = velocity;
        this->mass = mass;
		this->inverseMass = 1.0f / mass;
        damping = 1.0f;
        force = D3DXVECTOR3(0, 0, 0);
        acceleration = D3DXVECTOR3(0, 0, 0);
	}
	void update(float frameTime)
	{
		inverseMass = 1.0f / mass;
        if(inverseMass <= 0.0f)
        return;

        position += velocity * frameTime;
        D3DXVECTOR3 resultingAcc = acceleration + (force * inverseMass);
        velocity += resultingAcc * frameTime;
        velocity *= pow(damping, frameTime);

        force = D3DXVECTOR3(0, 0, 0);
	}
};

#endif 
